home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cpp-olib.zip / DOCS.ZIP / OBJEASE.DOC < prev    next >
Text File  |  1992-12-28  |  74KB  |  2,357 lines

  1.  
  2.  
  3.  
  4.                   ObjectEase v2.0
  5.  
  6.           (c)Copyright 1992 - David S. Reinhart Associates
  7.           1004 Marticville Rd. Pequea, PA  17565
  8.                   (717) 284-3736
  9.  
  10.  
  11.  
  12.     The ObjectEase libraries are for use with any and all versions
  13. of Borland's C++ compilers. 
  14.  
  15.  
  16.  
  17.  
  18.                   Welcome
  19.  
  20.     Welcome to the world of object oriented programming.  Welcome to 
  21. the world of ObjectEase!  The ObjectEase library of C++ classes and 
  22. member functions is going to do more for your programming efficiency 
  23. than any other library, book, video tape, or any other learning tool or 
  24. tool kit that you could purchase!  Guaranteed!   There is no learning 
  25. curve involved in using this library.  All of the classes are intuitive.  
  26. You've been using them in someone else's programs for years, but you've 
  27. just never been able to duplicate them in your own.  Not because you 
  28. don't have the programming skill, but because you didn't want to waste 
  29. time developing tools when you could spend your valuable time developing 
  30. a completed project. I, on the other hand have always been fascinated 
  31. with the tools that are used to piece together a successful application, 
  32. and that is what I have spent my time perfecting.  Now you can exploit 
  33. the work that I have already done by harnessing the power of the tools 
  34. that are contained in the ObjectEase class library!
  35.  
  36.     What is the prime advantage that we keep hearing about OBJECT 
  37. ORIENTED programming?  That's right... OBJECTS that can be pieced 
  38. together in various ways to form different applications.  Predefined 
  39. objects that YOU put together in whatever way you desire to produce your 
  40. programs.  You don't have to re-code anything.  Just include the 
  41. ObjectEase library in your project file and use these objects over and 
  42. over to produce PROFESSIONAL QUALITY, HIGHLY RESPECTED applications.
  43.  
  44.     Enough said!  If you haven't already done so, stop reading right 
  45. now and run the demo programs that have been provided.  The demos are 
  46. called TUIDEMO.EXE, GUIDEMO.EXE, and VIDDEMO.EXE and are in the 
  47. directory in which you have unpacked the ObjectEase DEMOS.ZIP files.  
  48. This is the quickest and easiest way to see for yourself the QUALITY, 
  49. EASE OF USE and POWER that YOU inherit through object oriented programming 
  50. using the ObjectEase library! Go ahead... try it now!!!
  51.  
  52.  
  53.  
  54.  
  55.                  Meet The Objects
  56.  
  57.     There are 23 object classes in this library.  "Only 23," you 
  58. ask...  Well, combined these 23 classes have over 500 member functions 
  59. that give you TOTAL control.  I dare say you will NEVER have the need to 
  60. use all 23 classes in the same application.  Some are exclusively for 
  61. text mode use, some for graphics mode.  Some to make things easier for 
  62. you, the programmer.  Some to make life easier for the end users of your 
  63. programs.  You will know, instinctively, which objects to use and in 
  64. which situations.  Let's take a look now at the objects, and later we'll 
  65. define all of the member functions for each.
  66.  
  67.  
  68.  
  69.  
  70.  
  71. TEXT MODE OBJECTS
  72.  
  73. Twindow         Pop up window object
  74. Tmenu           Point and shoot type menu object
  75. Tstring         String input object
  76. Tnumeral        Numeral (int,long,float) input object
  77. Tdate           Date input object
  78. Tbutton         Pushbutton object
  79. Tcheckbox       Checkbox object
  80.  
  81.  
  82. GRAPHICS MODE OBJECTS
  83.  
  84. Point           The base object for all other graphics objects
  85. Gstring         Graphics mode string input object
  86. Colorbutton     A generic object useful for such things as color
  87.           selection bars, as in paint programs
  88. Icon            Icon object used as a selection tool
  89. Acticon         Animated icons. Really! It's great!!!
  90. Gcheckbox       Graphics version of the checkbox object
  91. Gradio          Graphics mode radiobutton control
  92. Button          Graphic pushbuttons with both text and graphics
  93. Bitmap          Bitmap image object
  94. Panel           Sort of a graphics popup window object
  95. Bevel           Fancier version of the panel object
  96. Gmenu           Graphic pulldown menu
  97. Gmenubutton     Used to create a graphics mode menu bar
  98. Screen          Object determining the current mode and appearance
  99.             of the video screen
  100.  
  101. BI-MODAL OBJECTS
  102.  
  103. Mcursor         The mouse cursor
  104. SoundQ          Sound queue for playing music and sounds in the
  105.             background while other things keep happening in the
  106.             foreground                      
  107.  
  108.  
  109.     These objects provide you with all the power you need to quickly 
  110. piece together applications without wasting your time creating the 
  111. visual "tools" which control the program flow.  The tools are all here, 
  112. you just code in the appropriate reaction for every action!
  113.  
  114.     With this brief overview in hand, let's dive deeper into the world 
  115. of each of these objects. Let's find out what makes them tick, and how 
  116. YOU can control their every action.
  117.  
  118.  
  119.                  PART 1       
  120.  
  121.                 TEXT MODE OBJECTS
  122.  
  123.     Probably the vast majority of any programmer's work has been done 
  124. in the text mode, whether 80 or 40 column mode.  Most of the tools used 
  125. have been part of the standard library of functions supplied with the 
  126. compiler, if any!  Now you've got a new arsenal of tools which are as 
  127. powerful to employ as they are easy to implement.
  128.  
  129.     NOTE: These classes and member functions are supplied in the fol-
  130. lowing files:
  131.     TUI_S.LIB - Small memory model library
  132.     TUI_L.LIB - Large memory model library
  133.     TUI.H     - Header file
  134.  
  135.     See the source code for TUI.CPP for more examples of their use.
  136.  
  137. Twindow
  138.  
  139.     What program comes without at least one of these familiar fellows?  
  140. The popup window, useful and attractive for displaying and framing just 
  141. about any piece of information on the screen.  Sure, there are many C 
  142. libraries available for producing popup windows, but that's about all 
  143. they do!  And they don't do it with the ease and power available through 
  144. object oriented programming and the ObjectEase library!
  145.  
  146.  
  147. Twindow::Twindow()
  148.     The default constructor.
  149.  
  150.  
  151. Twindow::~Twindow()
  152.     The destructor.  Frees any and all memory associated with the
  153.     window.  Note that destructors are never directly callable.
  154.  
  155.  
  156. void Twindow::init(int xpos,int ypos,int x1pos,int y1pos,int fore,
  157.     int back,int shadow,int shadowcolor)
  158.     
  159.     The toughest function call you'll ever have to remember.
  160.     xpos - the upper left x coord of the window.
  161.     ypos - the upper left y coord of the window.
  162.     x1pos - the lower right x coord of the window. (NOT THE WIDTH)
  163.     y1pos - the lower right y coord of the window. (NOT THE HEIGHT)
  164.     fore - the foreground color used for drawing the lines.
  165.     back - the background color of the window.
  166.     shadow - 1 or 0. 1 represents the window has a shadow, 0 means
  167.     no shadow.
  168.     shadowcolor - 0 to 15 representing the color that any underlying
  169.     text that is in the shadow region will be shown as.  If there is 
  170.     no shadow this color should be 0. 
  171.  
  172.     example:        Twindow mainwindow;
  173.                 mainwindow.init(10,5,71,20,14,4,1,9);
  174.  
  175.  
  176. void Twindow::show()
  177.     Displays the window on the screen.  All underlying images are
  178.     saved so that the screen can later be restored.
  179.  
  180.     example:        Twindow mainwindow;
  181.                 mainwindow.init(10,5,71,20,14,4,1,9);
  182.                 mainwindow.show();
  183.  
  184.  
  185. void Twindow::zoom()
  186.     Displays the window on the screen, but with a "zoom" effect rather 
  187.     than an "all at once" approach.  Again, all underlying screen 
  188.     information is automatically saved.
  189.  
  190.  
  191.  
  192.  
  193.     example:        Twindow mainwindow;
  194.                 mainwindow.init(10,5,71,20,14,4,1,9);
  195.                 mainwindow.zoom();
  196.  
  197. void Twindow::hide()
  198.     Removes the window from the screen restoring the portion of the
  199.     screen which was obscured by the window.  Calling Twindow::hide
  200.     does not destroy the window.  The window can be re-shown at any
  201.     time as long as it is still in scope.
  202.  
  203.     example:        Twindow mainwindow;
  204.                 mainwindow.init(10,5,71,20,14,4,1,9);
  205.                 mainwindow.show();      //display the window
  206.                 getch();
  207.                 mainwindow.hide();      //remove the window
  208.                 getch();
  209.                 mainwindow.show();      //redisplay the window
  210.  
  211.  
  212. int Twindow::getborder() 
  213.     Returns the border style of the window.  The styles DOUBLE and
  214.     SINGLE are predefined in the header file.  SINGLE is the default
  215.     style unless otherwise specified.
  216.  
  217.     example:        Twindow mainwindow;
  218.                 mainwindow.init(10,5,71,20,14,4,1,9);
  219.                 mainwindow.show();
  220.                 if(mainwindow.getborder()==DOUBLE)
  221.                     printf("Double border");
  222.  
  223.  
  224. void Twindow::fill()
  225.     Fills the window with its current background color effectively
  226.     erasing anything that was shown in the window.
  227.  
  228.     example:        Twindow mainwindow;
  229.                 mainwindow.init(10,5,71,20,14,4,1,9);
  230.                 mainwindow.show();
  231.                 getch();
  232.                 mainwindow.wprintc(3,14,4,"Hi");// Print in 
  233.                                     // window  
  234.                 getch();
  235.                 mainwindow.fill();
  236.  
  237.  
  238. void Twindow::border()
  239.     Forces a redraw of the window's border.  Must be called after
  240.     the border style is changed.
  241.  
  242.     example:        Twindow mainwindow;
  243.                 mainwindow.init(10,5,71,20,14,4,1,9);
  244.                 mainwindow.show();
  245.                 mainwindow.setborder(DOUBLE);   //border is now 
  246.                                     //double
  247.                 mainwindow.border();            //must call to 
  248.                                     //show double 
  249.                                     //border 
  250.  
  251. int Twindow::setborder(int style)
  252.     Sets the current border style of the window to SINGLE or DOUBLE.
  253.     The new border style will not be shown until you call 
  254.     Twindow::border to redraw the window border.
  255.     
  256.     see example for Twindow::border() 
  257.  
  258.  
  259. void Twindow::cfgd(int fore)
  260.     Changes the window's foreground color to that specified in the
  261.     fore parameter.  The border (and only the border) is
  262.     automatically redrawn to reflect the new color.
  263.     
  264.     example:        Twindow mainwindow;
  265.                 mainwindow.init(10,5,71,20,14,4,1,9);
  266.                 mainwindow.show();
  267.                 getch();
  268.                 mainwindow.cfgd(15); fgd is now color 15
  269.  
  270.  
  271. void Twindow::cbgd(int back)
  272.     Changes the window's background color to that specified in the
  273.     back parameter.  The background is automatically redrawn in the
  274.     new color, effectively erasing anything that was in the window.
  275.     
  276.     example:        Twindow mainwindow;
  277.                 mainwindow.init(10,5,71,20,14,4,1,9);
  278.                 mainwindow.show();
  279.                 getch();
  280.                 mainwindow.cbgd(0); bgd is now color 0
  281.  
  282.  
  283. int Twindow::getfgd()
  284.     Returns the integer value of the window's current foreground
  285.     color. 
  286.     
  287.     example:        Twindow mainwindow;
  288.                 mainwindow.init(10,5,71,20,14,4,1,9);
  289.                 mainwindow.show();
  290.                 if(mainwindow.getfgd()==14)
  291.                     printf("The color is yellow");
  292.  
  293.  
  294. int Twindow::getbgd()
  295.     Returns the integer value of the window's background color.
  296.     
  297.     example:        Twindow mainwindow;
  298.                 mainwindow.init(10,5,71,20,14,4,1,9);
  299.                 mainwindow.show();
  300.                 if(mainwindow.getbgd()==4)
  301.                     printf("The background is red");
  302.  
  303.  
  304. void Twindow::divider(int direction,int style,int offset)
  305.     Creates a divider in the window in the direction of the
  306.     direction parameter, with the style of the style parameter and
  307.     offset spaces in from the top or left, depending on the
  308.     direction.  Use the predefined HOR and VER to represent
  309.     direction and SINGLE and DOUBLE to represent style.
  310.     
  311.     example:        Twindow mainwindow;
  312.                 mainwindow.init(10,5,71,20,14,4,1,9);
  313.                 mainwindow.show();
  314.                 getch();
  315.                 mainwindow.divider(HOR,SINGLE,3); 
  316.  
  317.  
  318. void Twindow::title(char txt[15])
  319.     Displays a title on the window in the upper left corner.
  320.     
  321.     example:        Twindow mainwindow;
  322.                 mainwindow.init(10,5,71,20,14,4,1,9);
  323.                 mainwindow.title(" MAIN ");
  324.                 mainwindow.show();
  325.  
  326.  
  327. int Twindow::isshown()
  328.     Returns 1 if the window is currently displayed on the screen, 0
  329.     otherwise.
  330.  
  331.     example:        Twindow mainwindow;
  332.                 mainwindow.init(10,5,71,20,14,4,1,9);
  333.                 if(!mainwindow.isshown())
  334.                     mainwindow.show();
  335.  
  336.  
  337. int Twindow::isx()
  338.     Returns the integer value of the upper left x coord
  339.  
  340.  
  341. int Twindow::isy()
  342.     Returns the integer value of the upper left y coord
  343.  
  344.  
  345. int Twindow::isx1()
  346.     Returns the integer value of the lower right x coord
  347.  
  348.  
  349. int Twindow::isy1()
  350.     Returns the integer value of the lower right y coord
  351.  
  352.  
  353. int Twindow::size()
  354.     Returns the size in bytes of the area occupied by the window.
  355.  
  356.  
  357. void Twindow::wprintat(int x,int y,int fgd,int bgd,char *txt)
  358.     Prints text relative to the window, not the screen, in the
  359.     specified foreground and background colors.
  360.  
  361.  
  362.     example:        Twindow mainwindow;
  363.                 mainwindow.init(10,5,71,20,14,4,1,9);
  364.                 mainwindow.show();
  365.                 mainwindow.wprintat(3,3,14,4,"This text is in 3 
  366.                     and down 3 from the upper left corner");
  367.  
  368. void Twindow::wprintc(int y,int fgd,int bgd,char *txt)
  369.     Centers text within a window on the given line and in the
  370.     specified foreground and background colors.
  371.  
  372.     example:        Twindow mainwindow;
  373.                 mainwindow.init(10,5,71,20,14,4,1,9);
  374.                 mainwindow.show();
  375.                 mainwindow.wprintc(2,14,4,"Centered on line 2");
  376.  
  377.  
  378.  
  379.  
  380.     So, what do you think?  Will these member functions give you all 
  381. the control over popup windows that you ever dreamed of or what?! Be 
  382. sure to see the code for the demo program for further examples of the 
  383. use of the member functions for the Twindow class.
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390. Tmenu
  391.  
  392.     Tmenu is the point and shoot menu object.  Being inherited from 
  393. Twindow, Tmenu automatically includes all of the functionality of the 
  394. Twindow class.  This means that practically anything you can do to a 
  395. Twindow instance you can also to with a Tmenu instance.  An "instance" 
  396. is an actual variable within your program of a given type. 
  397.  
  398.     Tmenu does not have its own constructor and destructor, but uses 
  399. those it inherits from Twindow.
  400.  
  401.  
  402. void Tmenu::init(int itemcnt,itemarray item,int xpos,int ypos,
  403.     int width,int fore,int back,int hfore,int hback,int shadow,
  404.     int shadowcolor)
  405.  
  406. Well, maybe Twindow::init wasn't the toughest! OK here goes.
  407.     itemcnt - the number of items in the menu.
  408.     item - type itemarray is defined in the header file.  You must
  409.         fill and itemarray structure with items and pass it to
  410.         Tmenu.   
  411.     xpos - the upper left x coord of the menu
  412.     ypos - the upper left y coord of the menu
  413.     width - the width in characters of the menu.  Make sure this is
  414.         wide enough to accomodate you longest menu entry.       
  415.     fore - the foreground color of the menu and unhighlighted text.
  416.     back - the background color of the menu and unhighlighted text.
  417.     hfore - the foreground color of the highlighted menu entry.
  418.     hback - the background color of the highlighted menu entry.
  419.     shadow - 0 for no shadow, 1 for a shadow.
  420.     shadowcolor - 0 to 15 representing the color of any text within
  421.         the shadow region.
  422.     example:        itemarray menuitems;
  423.                 Tmenu the_menu;
  424.                 
  425.                 strcpy(menuitems[1],"Number 1");
  426.                     //ALWAYS start with itemarray[1], NOT [0]
  427.                 strcpy(menuitems[2],"Number 2");
  428.                 strcpy(menuitems[3],"Number 3");
  429.                 
  430.                 the_menu.init(3,menuitems,5,2,10,15,1,1,7,0,0);
  431.                 the_menu.show();
  432.                 
  433.  
  434.  
  435. int Tmenu::show()
  436.     This function displays the menu, handles all keyboard input while 
  437.     the menu is displayed, and returns the integer value of the menu 
  438.     selection, providing the user pressed the <ENTER> key to make 
  439.     a selection.  If the user presses the <ESC> key the function 
  440.     returns 0. 
  441.     
  442.     example:        itemarray menuitems;
  443.                 Tmenu the_menu;
  444.                 int menuchoice;
  445.                 
  446.                 strcpy(menuitems[1],"Number 1");
  447.                 strcpy(menuitems[2],"Number 2");
  448.                 strcpy(menuitems[3],"Number 3");
  449.                 
  450.                 the_menu.init(3,menuitems,5,2,10,15,1,1,7,0,0);
  451.                 choice=the_menu.show();
  452.                 switch(choice) {
  453.                     case 1:printf("selection #1");
  454.                             break;
  455.                     case 2:printf("selection #2");
  456.                             break;
  457.                     case 3:printf("selection #3");
  458.                             break;
  459.                     case 0:printf("<ESC> key pressed");
  460.                     }
  461.                 the_menu.hide();//inherited from Twindow
  462.  
  463.  
  464.     This rounds out the Tmenu object, but don't forget that you can 
  465. use practically all of the Twindow member functions with the Tmenu class 
  466. as well!
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475. Tstring
  476.  
  477.  
  478.     The Tstring class is going to very quickly become one of your best 
  479. friends.  There is simply no easier way to get user text input from the 
  480. users of your programs than with Tstring and its children Tnumeral and 
  481. Tdate.  All of the standard editing keys (HOME, END, BACKWARD AND 
  482. FORWARD ARROWS, DELETE, BACKSPACE, ENTER, ESC...) are supported as well 
  483. as UP ARROW, DOWN ARROW, and TAB which allows you to EASILY create great 
  484. forms, something that I have found no other library function anywhere 
  485. could do the way I wanted to do.  Lets get to know your new best friend!
  486.  
  487.  
  488. Tstring::Tstring()
  489.     The default constructor.
  490.  
  491.  
  492. Tstring::~Tstring()
  493.     The default destructor.
  494.  
  495.  
  496. void Tstring::init(int xloc,int yloc,int len,int uppercase)
  497.     xloc - x coord for the left side of the string field.
  498.     yloc - y coord for the string field
  499.     len - the maximum length of the string field.
  500.     uppercase - 1 if the string should be all uppercase, 0 if case
  501.         is not important.
  502.         
  503.     example:        Tstring the_string;
  504.                 the_string.init(10,5,10,0);
  505.  
  506.  
  507. void Tstring::show()
  508.     Displays the input field on the screen, though it does not yet
  509.     become active.  This is helpful for displaying all of the fields 
  510.     in a form at one time.
  511.     
  512.     example:        Tstring the_string;
  513.                 the_string.init(10,5,10,0);
  514.                 the_string.show();
  515.  
  516.  
  517. void Tstring::input()
  518.     Checks for an input character, and immediately exits if there is
  519.     none. This function can be useful for apparent multitasking. 
  520.  
  521.     example:        Tstring the_string;
  522.                 int x=0;
  523.                 the_string.init(10,5,10,0);
  524.                 the_string.show();
  525.  
  526.                 while(1) {
  527.                     the_string.input();
  528.                     gotoxy(1,1);
  529.                     printf("%5d",x++);
  530.                     }
  531.  
  532.  
  533.     Even though you can continue to edit the Tstring instance, the
  534.     variable x keeps incrementing and displaying to the screen.
  535.  
  536.  
  537. void Tstring::get_input()
  538.     This is the function that you will most commonly call for single
  539.     string input.  Basically this function continually calls
  540.     Tstring::input() and exits when the user presses either the ENTER
  541.     key or the ESC key.  Even if the user presses ESC anything in the
  542.     input field will be captured and can be retrieved, though this is
  543.     not generally the case.
  544.  
  545.     example:        Tstring the_string;
  546.                 the_string.init(10,5,10,0);
  547.                 the_string.get_input();//automatically calls
  548.                     //Tstring::show if the field is not 
  549.                     //already displayed. 
  550.                 if(the_string.escapehit())
  551.                     exit(0);
  552.  
  553.  
  554. int Tstring::escapehit()
  555.     Returns 1 if the ESC key was been pressed to end editing of a
  556.     field. 
  557.  
  558.     See example for Tstring::get_input().
  559.  
  560.  
  561. int Tstring::returnhit()
  562.     Returns 1 if the ENTER key was pressed to end editing of a field.
  563.  
  564.     example:        Tstring the_string;
  565.                 the_string.init(10,5,10,0);
  566.                 the_string.get_input();
  567.                 if(the_string.returnhit())
  568.                     printf("\a");
  569.  
  570.  
  571. int Tstring::tabhit()
  572.     Returns 1 if the TAB key was pressed while editing a field.
  573.  
  574.     example:        Tstring the_string;
  575.                 the_string.init(10,5,10,0);
  576.                 the_string.get_input();
  577.                 if(the_string.tabhit())
  578.                     printf("\a");
  579.  
  580.  
  581. int Tstring::uparrowhit()
  582.     Returns 1 if the UP ARROW key was pressed while editing a field.
  583.     This function is very useful for form input and is used with the
  584.     Tstring::get_form_input member function.
  585.  
  586.     See the example with the Tstring::get_form_input() function.
  587.  
  588.  
  589.  
  590. int Tstring::dnarrowhit()
  591.     Returns 1 if the DOWN ARROW key was pressed while editing a field. 
  592.     This function is very useful for form input and is used with the 
  593.     Tstring::get_form_input member function.
  594.  
  595.     See the example with the Tstring::get_form_input() function.
  596.  
  597.  
  598. int Tstring::isshown()
  599.     Returns 1 if the string field has been displayed on the screen,
  600.     0 if not.
  601.  
  602.  
  603. int Tstring::hit()
  604.     Returns 1 if the left mouse button is pressed while the mouse
  605.     cursor is on the string field.  This function is used in
  606.     conjunction with the Tstring::get_form_mouse_input() function.
  607.  
  608.     example:        Tstring the_string;
  609.                 extern Mcursor the_mouse;       //See Mcursor for 
  610.                                     //details.
  611.  
  612.                 the_string.init(10,5,10,0);
  613.                 the_mouse.init();                       //See Mcursor
  614.                 the_mouse.show();                       //See Mcursor
  615.                 the_string.get_form_mouse_input();
  616.                 if(the_string.hit())
  617.                     printf("\a);
  618.  
  619.  
  620. void Tstring::setincolors(int fgd,int bgd)
  621.     Sets the foreground and background colors of the input field.
  622.     By default these colors will be yellow (14) on blue (1).  Use this
  623.     member function to change these default values.
  624.     
  625.     example:        Tstring the_string;
  626.                 the_string.init(10,5,10,0);
  627.                 the_string.setincolors(0,7);
  628.                 the_string.get_input();
  629.  
  630.  
  631. void Tstring::get_form_input()
  632.     VERY useful function for getting input in form fashion from the
  633.     user.  I remember reading when I first learned Pascal that a
  634.     skilled Pascal programmer would never use a GOTO statement, but
  635.     would find a more elegant way control program flow.  BULL!
  636.     Skillful use of a GOTO statement can be very powerful indeed as
  637.     we will now see.
  638.     
  639.     example:        Tstring string1;
  640.                 Tstring string2;
  641.                 Tstring string3;
  642.                 
  643.                 string1.init(10,5,10,0);
  644.                 string2.init(10,7,10,0);
  645.                 string3.init(10,9,10,0);
  646.                 
  647.                 string1.show();
  648.                 string2.show();
  649.                 string3.show();
  650.  
  651.  
  652.             getstring1:                     //This is a label
  653.                 string1.get_form_input();
  654.                 if(string1.escapehit()) goto esc;
  655.                 if(string1.uparrowhit()) goto getstring3;
  656.                 if(string1.dnarrowhit()) goto getstring2;
  657.  
  658.             getstring2:                     //Another label
  659.                 string2.get_form_input();
  660.                 if(string2.escapehit()) goto esc;
  661.                 if(string2.uparrowhit()) goto getstring1;
  662.                 if(string2.dnarrowhit()) goto getstring3;
  663.  
  664.             getstring3:                     //And another
  665.                 string3.get_form_input();
  666.                 if(string3.escapehit()) goto esc;
  667.                 if(string3.uparrowhit()) goto getstring2;
  668.                 if(string3.dnarrowhit()) goto getstring1;
  669.                 goto continue;
  670.             esc:
  671.                 exit(0);
  672.             continue:
  673.                 ...  //program continues.
  674.  
  675.     In this way a user can move continuously among the different
  676.     input fields until everything is perfect before leaving this
  677.     particular screen.
  678.  
  679.  
  680. void Tstring::get_form_mouse_input()
  681.     This function is very similar to Tstring::get_form_input, but it
  682.     also checks to see if you have clicked the left mouse button on
  683.     another field within the form. 
  684.     
  685.     example:        Tstring string1;
  686.                 Tstring string2;
  687.                 extern Mcursor the_mouse;       //See Mcursor
  688.  
  689.                 the_mouse.init();
  690.                 the_mouse.show();
  691.                 string1.init(10,5,10,0);
  692.                 string2.init(10,7,10,0);
  693.  
  694.             getstring1:
  695.                 string1.get_form_mouse.input();
  696.                 if(the_mouse.LBP()) {           //See Mcursor
  697.                     if(string2.hit()) goto getstring2;
  698.             getstring2:
  699.                 string2.get_form_mouse_input();
  700.                 if(the_mouse.LBP()) {
  701.                     if(string1.hit()) goto getstring1;
  702.  
  703. char * Tstring::getstring()
  704.     Returns a pointer to the string that the Tstring instance
  705.     contains.  This is the only way to get at the contents of the
  706.     Tstring input field.
  707.  
  708.     example:        Tstring the_string;
  709.                 the_string.init(10,5,10,0);
  710.                 the_string.get_input();
  711.                 printf("%s",the_string.getstring());
  712.  
  713.  
  714. void Tstring::preset(char *)
  715.     Use this function to automatically display a predefined string
  716.     in the input field.  The user can still edit this field in the
  717.     usual manner.
  718.  
  719.     example:        Tstring the_string;
  720.                 the_string.init(10,5,10,0);
  721.                 the_string.preset("Yes");
  722.                 the_string.get_input();
  723.  
  724.  
  725. void Tstring::reset()
  726.     Clears the contents of a Tstring input field.
  727.  
  728.     example:        Tstring the_string;
  729.                 char stringholder[80];
  730.  
  731.                 the_string.init(10,5,10,0);
  732.                 the_string.get_input();
  733.                 strcpy(stringholder,the_string.getstring());
  734.                 the_string.reset();
  735.                 the_string.show();
  736.  
  737.  
  738. void Tstring::erase()
  739.     Clears the contents of a Tstring input field and automatically
  740.     redisplays the blank field on the screen.
  741.  
  742.     example:        Tstring the_string;
  743.                 char stringholder[80];
  744.  
  745.                 the_string.init(10,5,10,0);
  746.                 the_string.getinput();
  747.                 strcpy(stringholder,the_string.getstring());
  748.                 the_string.erase();
  749.  
  750.  
  751.     That wraps it up for the Tstring class. VERY POWERFUL STUFF!!! You 
  752. can do some incredible things with this class and its member functions, 
  753. and the best part is that you can do them EASILY! Now let's take a look 
  754. at Tstring's descendants, Tnumeral and Tdate.
  755.  
  756.  
  757.  
  758.  
  759. Tnumeral
  760.  
  761.  
  762.     Being descended from Tstring, Tnumeral of course inherits all of 
  763. Tstring's power and ease of use. Some member functions, however, have 
  764. been modified somewhat for the particulars of a numeral class as opposed 
  765. to a string class. Let's examine Tnumeral's member functions.
  766.  
  767. void Tnumeral::init(int xpos,int ypos,int length,int int_or_float)
  768. This member function looks similar to that of Tstring, but some 
  769.     particulars have been changed. The first three parameters again          
  770.     refer to the x and y screen coordinates for the input field to 
  771.     begin, and the length of the input field respectively. The fourth 
  772.     parameter now specifies whether or not the field is to display an 
  773.     integer or a float value. 
  774.  
  775.     int_or_float - 0 for int or long values, 1 for float values.
  776.  
  777.     example:        Tnumeral the_int;
  778.             Tnumeral the_float;
  779.                 the_int.init(10,10,5,0);
  780.                 the_float.init(10,12,5,1);
  781.  
  782.  
  783. int Tnumeral::getint()
  784.     Returns the integer value input by the user.
  785.  
  786.     example:        Tnumeral the_int;
  787.             int myint;
  788.                 the_int.init(10,10,5,0);
  789.                 the_int.get_input();
  790.                 myint=the_int.getint();
  791.  
  792.  
  793. long Tnumeral::getlong()
  794.     Returns a long value input by the user.
  795.  
  796.     example:        Tnumeral the_long;
  797.             long mylong;
  798.                 the_long.init(10,10,5,0);
  799.                 the_long.get_input();
  800.                 mylong=the_long.getlong();
  801.  
  802. float Tnumeral::getfloat()
  803.     Returns a float value input by the user.
  804.  
  805.     example:        Tnumeral the_float;
  806.             float myfloat;
  807.                 the_float.init(10,10,5,1);
  808.                 the_float.get_input();
  809.                 myfloat=the_float.getfloat();
  810.  
  811.  
  812.     These are the specifics of the Tnumeral class. Don't forget that 
  813. you can still use any of the member functions inherited from the Tstring 
  814. class. This is the essential power of object oriented programming!
  815.  
  816. Tdate
  817.  
  818.     The Tdate class is a specialized version of the Tstring class used 
  819. specifically for entering date information. Slashes will be displayed in 
  820. the input field at the appropriate places, and all user input will take 
  821. place around these slashes, never overwriting them or requiring the user 
  822. to forward space over them. When the user presses <ENTER> the date value 
  823. will be validated, and if the date is not valid a warning beep will 
  824. sound and editing will continue until a valid date is entered or the 
  825. user presses <ESC>.
  826.  
  827.  
  828. void Tdate.init(int xpos,int ypos)
  829.     xpos - the x screen coordinate at which to begin the date field.
  830.     ypos - the y screen coordinate at which to begin the date field.
  831.  
  832.     example:        Tdate the_date;
  833.                 the_date.init(10,10);
  834.  
  835.  
  836. int Tdate::verified()
  837.     Returns 0 if the date entered is NOT a valid date, 1 if it is 
  838.     valid.
  839.  
  840.     example:        Tdate the_date;
  841.             int date_is_OK=0;
  842.                 the_date.init(10,10);
  843.                 the_date.get_input();
  844.                 if(the_date.verified())
  845.                     date_is_OK=1;
  846.  
  847.  
  848. char * Tdate::getdatestring()
  849.     Returns a character string representing the date as literally 
  850.     entered by the user. An example of a string returned by this 
  851.     function would be "06/06/92".
  852.  
  853.     example:        Tdate the_date;
  854.             char mydate[8];
  855.                 the_date.init(10,10);
  856.                 the_date.get_input();
  857.                 strcpy(mydate,the_date.getdatestring());
  858.  
  859.  
  860. long Tdate::getdate()
  861.     Returns a long number representing the date as entered by the 
  862.     user. If the user entered a date of 01/13/64 the Tdate::getdate 
  863.     function would return a value of 640113. This value is useful for 
  864.     comparing two or more dates.
  865.  
  866.     example:        Tdate the_date;
  867.             long mydate;
  868.                 the_date.init(10,10);
  869.                 the_date.get_input();
  870.                 mydate=the_date.getdate();
  871.  
  872.  
  873.     That's all there is to tell about Tstring and its descendants 
  874. Tnumeral and Tdate. As stated earlier, I'm sure these classes are going 
  875. to make life much easier for you, the programmer, as well as the users 
  876. of your programs. Now let's move on to explore some of the other text 
  877. mode objects of the ObjectEase library.
  878.  
  879.  
  880.  
  881.  
  882. Tbutton
  883.  
  884.     Tbutton is the class which represents the text mode pushbutton. 
  885. With the growing popularity of the GUI and mouse usage, text mode 
  886. graphic objects also become increasingly necessary if your programs are 
  887. to remain efficient and easy to use. The Tbutton class is just for this 
  888. purpose. Sometimes a menu is just too much, and that is where the 
  889. Tbutton excels. Tbuttons can be activated by the mouse or by a keyboard 
  890. trigger. The usual keyboard trigger is the ALT key in combination with 
  891. the highlighted letter from the Tbutton. This is the method the will be 
  892. used in the following examples.
  893.  
  894. Tbutton::Tbutton()
  895.     The default constructor.
  896.  
  897.  
  898. Tbutton::~Tbutton()
  899.     The default destructor.
  900.  
  901.  
  902. void Tbutton::init(int xpos,int ypos,char* text,int highlight)
  903.     xpos - the x screen coordinate to display the Tbutton.
  904.     ypos - the y screen coordinate to display the Tbutton.
  905.     text - the string to be displayed on the Tbutton.
  906.     highlight - the position within the string of the letter to 
  907.     highlight (for use as a keyboard trigger).
  908.  
  909.     example:        Tbutton mybutton;
  910.                 mybutton.init(10,10,"Hello",1);
  911.                 //The 'H' in Hello, being the first letter, will 
  912.                 //be highlighted.
  913.  
  914.  
  915. void Tbutton::show(int bgd)
  916.     Displays the Tbutton instance on the screen. The bgd parameter is 
  917.     the color of the background on which the Tbutton instance will be 
  918.     displayed.
  919.  
  920.     example:        Tbutton mybutton;
  921.                 mybutton.init(10,10,"Hello",1);
  922.                 settextbackground(1);
  923.                 clrscr();
  924.                 mybutton.show(1);
  925.  
  926.  
  927.  
  928. int Tbutton::hit()
  929.     Returns 1 if the mouse cursor is on the Tbutton, 0 otherwise.
  930.  
  931.     example:        Tbutton mybutton;
  932.             Mcursor the_mouse;      //see Mcursor class
  933.                 mybutton.init(10,10,"Hello",1);
  934.                 mybutton.show(0);
  935.                 if(the_mouse.LBP()) {
  936.                     if(mybutton.hit()) {
  937.                         mybutton.press(0);
  938.                         while(the_mouse.LBP());
  939.                         mybutton.show(0);
  940.                         }
  941.                     }
  942.  
  943.  
  944. void Tbutton::press(int bgd)
  945.     Displays the Tbutton on the screen in the depressed mode.
  946.  
  947.     See the example for Tbutton::hit()
  948.  
  949.  
  950. int Tbutton.ispressed()
  951.     Returns 1 if the Tbutton instance is in the depressed state, 0 
  952.     otherwise.
  953.  
  954.     example:        Tbutton mybutton;
  955.                 mybutton.init(10,10,"Hello",1);
  956.                 mybutton.show(0);
  957.                 if(!mybutton.ispressed()) 
  958.                     mybutton.press(0);
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.     These examples have shown how to activate a Tbutton instance using 
  966. the mouse as a trigger. Let me now provide an example of how to use the 
  967. keyboard as a trigger. I will be using some additional functions in this 
  968. example which ARE included in the ObjectEase library even though they 
  969. are not member functions of a particular class.
  970.  
  971.     example:        Tbutton mybutton;
  972.             char ch;
  973.                 mybutton.init(10,10,"Hello",1);
  974.                 settextbackground(1);
  975.                 clrscr();
  976.                 mybutton.show(1);
  977.  
  978.                 ch=getch();
  979.                 if(altkey()) {  //included function
  980.                     ch=getch();
  981.                     if(ch==ALTH) {  //defined in the                
  982.                                 //included header file
  983.                         mybutton.press(1);
  984.                         while(altkey());
  985.                         mybutton.show(1);
  986.                         //branch here to any action
  987.                         }
  988.                     }
  989.  
  990.  
  991.     Again, see the source code for the demo program for further 
  992. examples if this is not totally clear to you.
  993.  
  994.  
  995.  
  996.  
  997. Tcheckbox
  998.  
  999.  
  1000.     The Tcheckbox class allows you to offer multiple choices and have 
  1001. the user make multiple selections. You can then "ask" the Tcheckbox if 
  1002. it has been checked by the user and take the appropriate actions. The 
  1003. mouse or the keyboard can act as a trigger to toggle the state of a 
  1004. Tcheckbox. When the keyboard is used, it is usually the SPACE BAR that 
  1005. serves as the trigger. Let's see how...
  1006.     
  1007.  
  1008. void Tcheckbox::init(int xpos,int ypos,int fgd,int bgd)
  1009.     xpos - the x screen coordinate of the Tcheckbox.
  1010.     ypos - the y screen coordinate of the Tcheckbox.
  1011.     fgd - the foreground color to use for the Tcheckbox.
  1012.     bgd - the background color to use for the Tcheckbox.
  1013.  
  1014.     example:        Tcheckbox mybox;
  1015.                 mybox,init(10,10,15,0);
  1016.  
  1017.  
  1018. void Tcheckbox::show()
  1019.     Displays the Tcheckbox instance on the screen.
  1020.  
  1021.     example:        Tcheckbox mybox;
  1022.                 mybox.init(10,10,15,0);
  1023.                 mybox.show();
  1024.  
  1025.  
  1026. void Tcheckbox::check()
  1027.     Displays an 'X' in the Tcheckbox, marking it as selected.
  1028.  
  1029.     example:        Tcheckbox mybox;
  1030.                 mybox.init(10,10,15,0);
  1031.                 mybox.show();
  1032.                 mybox.check();
  1033.  
  1034.  
  1035.  
  1036.  
  1037. void Tcheckbox::uncheck()
  1038.     Clears the 'X' from a checked Tcheckbox.
  1039.  
  1040.     example:        Tcheckbox mybox;
  1041.                 mybox.init(10,10,15,0);
  1042.                 mybox.show();
  1043.                 getch();
  1044.                 mybox.check();
  1045.                 getch();
  1046.                 mybox.uncheck();
  1047.  
  1048. int Tcheckbox.ischecked()
  1049.     Returns 1 if the Tcheckbox is checked, 0 otherwise.
  1050.  
  1051.     example:        Tcheckbox mybox;
  1052.                 mybox.init(10,10,15,0);
  1053.                 mybox.show();
  1054.                 mybox.check();
  1055.                 if(mybox.ischecked())
  1056.                     mybox.uncheck();
  1057.                 else
  1058.                     mybox.chech();
  1059.  
  1060.  
  1061. void Tcheckbox::grabcursor()
  1062.     Moves the cursor to a particular Tcheckbox instance.
  1063.  
  1064.     example:        Tcheckbox mybox;
  1065.                 mybox.init(10,10,15,0);
  1066.                 clrscr(); //cursor is now at 1,1
  1067.                 mybox.show();
  1068.                 mybox.grabcursor(); //cursor is now at mybox
  1069.  
  1070.  
  1071. int Tcheckbox::hit()
  1072.     Returns 1 if the mouse cursor is on the Tcheckbox, 0 otherwise.
  1073.  
  1074.     example:        Tcheckbox mybox;
  1075.             Mcursor the_mouse;  //See Mcursor
  1076.  
  1077.                 mybox.init(10,10,15,0);
  1078.                 mybox.show();
  1079.                 if(the_mouse.LBP()) {
  1080.                     if(mybox.hit()) {
  1081.                         if(mybox.ischecked())
  1082.                             mybox.uncheck();
  1083.                         else
  1084.                             mybox.check();
  1085.                         while(the_mouse.LBP());
  1086.                         }               
  1087.                     }
  1088.  
  1089.  
  1090.     Let me now give an example of how to use the keyboard to toggle 
  1091. the state of a Tcheckbox instance.
  1092.  
  1093.     example:        Tcheckbox mybox;
  1094.             char ch;
  1095.             int done=0;
  1096.  
  1097.                 mybox.init(10,10,15,0);
  1098.                 mybox.show();
  1099.                 mybox.grabcursor();
  1100.                 while(!done) {
  1101.                     ch=getch();
  1102.                     if(ch==32) {
  1103.                         if(mybox.ischecked())
  1104.                             mybox.uncheck();
  1105.                         else
  1106.                             mybox.check();
  1107.                         }
  1108.                     }
  1109.  
  1110.     
  1111.     This concludes the text mode class descriptions. In the next 
  1112. section we will look at the graphic mode objects in detail.
  1113.  
  1114.  
  1115.                   PART 2
  1116.                 GRAPHICS MODE OBJECTS
  1117.  
  1118.  
  1119.       Using the graphic objects of the ObjectEase library
  1120.  
  1121.     In order to utilize the objects and functions in the ObjectEase
  1122. library you need only add the GUI.LIB library to your project, and 
  1123. include the header file in your program code. You can then declare 
  1124. object instances and call the functions as you would with any other 
  1125. library. You must, of course, first initialize the graphics mode with a 
  1126. call to initgraph(), or preferably through one of the member functions 
  1127. of the screen class. The graphic objects are available only in the large 
  1128. memory model of the library. This is because the use of graphics 
  1129. can be very memory intensive and the large memory model gives the 
  1130. program access to all of the available RAM, not just a single 64K 
  1131. data segment.
  1132.  
  1133.     This documentation is divided into sections describing each of the 
  1134. various graphic objects followed by a description and examples of 
  1135. all of the methods that may be used with the object. Please take 
  1136. special note of the example fragments as they may be of great help 
  1137. to you in getting to know the proper use of these objects and 
  1138. methods. 
  1139.  
  1140.     The following classes are available in these files:
  1141.  
  1142.     GUI.LIB - Large memory model library
  1143.     GUI.H   - Header file
  1144.  
  1145.     See the source code for the sample program GUIDEMO.EXE for
  1146.     more examples of these classes and their use.
  1147.  
  1148. Panels
  1149.  
  1150.     Panels can be associated with pop-up windows in a text 
  1151. environment. They serve to contain and draw attention to other objects 
  1152. such as text or pushbuttons. 
  1153.  
  1154.     The class POINT from which Panel is derived is the base class for 
  1155. all of the graphic objects in this library.
  1156.  
  1157.     In order to facilitate the initialization of the inorout and 
  1158. thickorthin variables the definitions IN, OUT, THICK and THIN 
  1159. may be used. These are defined in the header file.
  1160.  
  1161.     To declare an instance of class PANEL and display it in your 
  1162. application follow the example in the following code fragment.
  1163.  
  1164.     Panel mypanel;
  1165.     mypanel.init(10,10,100,100,IN,THICK);
  1166.     mypanel.show();
  1167.  
  1168.     It's just that simple. Remember that the graphics mode must first 
  1169. be initialized by a call to initgraph. If you are unfamiliar with 
  1170. this function consult your compiler documentation.
  1171.  
  1172.     All of the objects in this library contain the method "init". 
  1173. You must call "init" with the proper parameters before trying 
  1174. to display the object. There's no telling what might happen if 
  1175. you try to display an uninitialized object.
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181. Bevels
  1182.  
  1183.  
  1184.     Bevels are just like panels with a more decorative border. All 
  1185. calls to their methods are identical except that a call to 
  1186. Bevel.init() takes one less parameter. You do not need to specify 
  1187. IN or OUT because Bevel borders always go out. 
  1188.  
  1189.  
  1190.  
  1191. PushButtons
  1192.  
  1193.  
  1194.     Pushbuttons simulate keyboard keys on the screen. They serve to 
  1195. get user input for a variety of purposes. They are very intuitive 
  1196. and can display either a text title or a graphic image.
  1197.  
  1198.     To declare an instance of class Button you need to supply the 
  1199. parameters for the upper left x and y positions, a string which 
  1200. either represents the text to be displayed on the button or the 
  1201. name of the file containing the image to be used on the button, 
  1202. and an integer flag representing whether or not the last parameter 
  1203. refers to text or a filename.
  1204.  
  1205. The definitions TEXT and IMAGE can be used in this parameter and are 
  1206. defined in the header file.
  1207.  
  1208.     Consider this example:
  1209.  
  1210.     Button textbutton;
  1211.     textbutton.init(10,10," EXIT ",TEXT);
  1212.     textbutton.show();
  1213.  
  1214.     This would create and display a button that said " EXIT " on it.
  1215.  
  1216.     Consider this:
  1217.  
  1218.     Button graphbutton;
  1219.     graphbutton.init(10,10,"EXIT",IMAGE);
  1220.     graphbutton.show();
  1221.  
  1222.     This would create and display a button containing the image stored 
  1223. in the file "EXIT.BTN". The file extension should not be included 
  1224. in the parameter as ".BTN" is the assumed extension. The graphic 
  1225. file must be present on the disk before trying to call this function. 
  1226.  
  1227.     Using the ICONEDIT program supplied with this package you can very 
  1228. easily create these graphics to be included on buttons.
  1229.  
  1230.     Note that you do not need to specify the width and height of 
  1231. buttons. If you are using text labels the button width is determined 
  1232. automatically to accomodate up to 40 characters, and if your are using 
  1233. graphics the button defaults to 20x20. This is the size of the button 
  1234. graphics created by the ICONEDIT program.
  1235.  
  1236.     Pressing the button is usually done with the mouse cursor, 
  1237. however, you may find it useful to use some other trigger to press the 
  1238. button. 
  1239.  
  1240.     The button method "hit()" determines if the mouse cursor is within 
  1241. the boundaries of the button. For a detailed discussion on the use of 
  1242. the mouse functions see the appropriate section of this documentation. 
  1243. If you don't understand all of the functions in this next code fragment 
  1244. you can find explanations elsewhere in this document.
  1245.  
  1246.     Button mybutton;                       DECLARES INSTANCE OF BUTTON
  1247.     mybutton.init(10,10,"EXIT",TEXT);      INITIALIZES MYBUTTON
  1248.     mybutton.show();                       DISPLAYS MYBUTTON ON SCREEN
  1249.  
  1250.     while(!kbhit()) {                      DO THIS WHILE NO KEYS ARE        
  1251.                              HIT
  1252.       if(the_mouse.LBP()) {                IF THE LEFT MOUSE KEY IS
  1253.                          PRESSED
  1254.         if(mybutton.hit()) {               IF MOUSE CURSOR IS ON    
  1255.                              MYBUTTON
  1256.           mybutton.press();                DISPLAY MYBUTTON AS PRESSED
  1257.           while(the_mouse.LBP());          WAIT UNTIL LEFT MOUSE KEY        
  1258.                              HAS BEEN RELEASED
  1259.           mybutton.show();                 DISPLAY MYBUTTON IN NORMAL 
  1260.                          STATE
  1261.           }
  1262.       }
  1263.     }                       
  1264.  
  1265.     Immediately after restoring the button to the normal (undepressed) 
  1266. state the program can branch to take whatever action the button 
  1267. calls for.  By using the Button method "press()" all of the 
  1268. redrawing and repositioning of the text and/or graphic images is 
  1269. handled automatically by the ObjectEase library.
  1270.  
  1271.  
  1272. Colorbuttons
  1273.  
  1274.  
  1275.     Colorbuttons don't do much except tell you when they are hit and
  1276. return their current color. This is very useful if you are coding a 
  1277. paint program and need some way to set the current foreground and 
  1278. background colors. I'm sure you can find some other good uses for this 
  1279. class as well.
  1280.  
  1281.     Call "init()" with integer parameters for the x and y position,
  1282. the width, the height, and the color of the button. Call "show()" with
  1283. an integer value representing the color of the rectangle you wish to 
  1284. have surrounding the Colorbutton. By manipulating this value you can 
  1285. effectively show an "active" Colorbutton in a row of Colorbuttons. 
  1286. "Hit()" simply returns whether or not the mouse cursor is in the 
  1287. Colorbutton area, and "getcolor()" returns the color of the Colorbutton.
  1288.  
  1289.  
  1290.  
  1291.  
  1292.     A quick way to make a color selection bar is as follows:
  1293.  
  1294.     Colorbutton colorarray[16];
  1295.     for(int i=0;i<16;i++) {
  1296.         colorarray[i].init(100+(i*20),100,20,20,i);
  1297.         colorarray[i].show(15);
  1298.         }
  1299.  
  1300.  
  1301.  
  1302. Gcheckbox
  1303.  
  1304.     The Gcheckbox is the graphics mode counterpart to the Tcheckbox   
  1305. class. Like the Tcheckbox, Gcheckbox should be used to allow the user to 
  1306. make multiple selections. Call "init()" with the following three 
  1307. parameters to initialize a Gcheckbox. The x int coordinate, the y int 
  1308. coordinate, and a char * representing the descriptive text to be 
  1309. displayed with the Gcheckbox. Call "show()" to display the Gcheckbox on 
  1310. the screen. Calling "check()" and "uncheck()" will toggle the state of 
  1311. the Gcheckbox, and calling "is_checked()" will tell you its current 
  1312. state. The "hit()" member function returns true if the mouse cursor is 
  1313. positioned on the Gcheckbox.
  1314.  
  1315.     Follow this example:
  1316.  
  1317.     Gcheckbox mybox;
  1318.     int done=0;
  1319.  
  1320.     mybox.init(100,100,"This is a Gcheckbox");
  1321.     mybox.show();
  1322.     while(!done) {
  1323.         if(the_mouse.LBP()) {
  1324.             if(mybox.hit()) {
  1325.                 if(mybox.is_checked())
  1326.                     mybox.uncheck();
  1327.                 else
  1328.                     mybox.check();
  1329.                 }
  1330.             }
  1331.         }
  1332.  
  1333.  
  1334.     You don't have to use the mouse as the trigger to toggle states. 
  1335. Any keypress or key combination that you choose can be used to toggle 
  1336. the state.
  1337.  
  1338.  
  1339.  
  1340. Gradio
  1341.  
  1342.     Gradio is the graphics mode version of the radio button. Basically 
  1343. the way a radio button works is this: First, you must have more than one 
  1344. of them. If you only need one use a Gcheckbox instead. One of the series 
  1345. of Gradios is initially selected. When the user selects a different 
  1346. radio button, the first one becomes de-selected, and the new one becomes 
  1347. selected, and so on. Remember, unlike a series of Gcheckboxes, only ONE 
  1348. Gradio can be selected at a time.
  1349.  
  1350.     Initialize a Gradio by calling "init()" with three parameters. The 
  1351. first two are ints specifying the x and y coordinates respectively to 
  1352. display the Gradio, and the third is a char* representing the 
  1353. descriptive text to be displayed to the right of the Gradio. After 
  1354. initializing the Gradio you can show it with a call to "show()". Like a 
  1355. Gcheckbox you can toggle the state of a Gradio with calls to "check()" 
  1356. and "uncheck()", and test if it has been hit with the mouse cursor by 
  1357. calling "hit()". Calling "is_checked()" will tell you the current state 
  1358. of the Gradio.
  1359.  
  1360.     Let's look at an example:
  1361.     
  1362.     Gradio rb1,rb2;
  1363.     int done=0;
  1364.  
  1365.     rb1.init(100,100,"This is a radio button");
  1366.     rb2.init(100,120,"So is this");
  1367.     rb1.show();
  1368.     rb2.show();
  1369.     while(!done) {
  1370.         if(the_mouse.LBP()) {
  1371.             if(rb1.hit()) {
  1372.                 if(rb1.is_checked()) {
  1373.                     rb1.uncheck();
  1374.                     rb2.check();
  1375.                     }
  1376.                 else {
  1377.                     rb1.check();
  1378.                     rb2.uncheck();
  1379.                     }
  1380.             if(rb2.hit()) {
  1381.                 if(rb2.is_checked()) {
  1382.                     rb2.uncheck();
  1383.                     rb1.check();
  1384.                     }
  1385.                 else {
  1386.                     rb2.check();
  1387.                     rb1.uncheck();
  1388.                     }                                       
  1389.                 }
  1390.             }
  1391.         }
  1392.  
  1393.  
  1394. Icons
  1395.  
  1396.     Icons can be used in much the same way as buttons. They will 
  1397. always contain a graphic image, although text can be a part of the 
  1398. graphic. They are not 3 dimensional like pushbuttons.
  1399.  
  1400.     The graphic images for these Icon objects are created using the 
  1401. ICONEDIT program. This program produces 32x32 pixel icons that can be 
  1402. single or multi-framed. More on this in a moment.
  1403.  
  1404.     Like the other graphic objects, the Icon class must first be 
  1405. initialized with a call to "init()." Init() takes three parameter, 
  1406. the x and y coordinates of the upper left corner, and the file name 
  1407. of the file containing the graphic image for the icon. The filename 
  1408. parameter should be given without an extension as the default 
  1409. extension ".ICN" is assumed. The file named in this parameter must 
  1410. exist in the current directory.
  1411.  
  1412.     Let's look at a short example:
  1413.  
  1414.     Icon myicon;
  1415.     myicon.init(10,10,"paint");
  1416.     myicon.show();
  1417.  
  1418.     This example declares an instance of class Icon using the file 
  1419. "paint.icn" as the graphic, and then displays the icon.
  1420.  
  1421.     As with the pushbutton, the method "hit()" determines if the 
  1422. mouse cursor is within the boundaries of the icon. If it is, 
  1423. and if a mouse key is pressed, we can change the appearance of 
  1424. the icon to mark it as selected using the method "choose()." Here's 
  1425. a quick example, similar to that presented for the pushbutton:
  1426.  
  1427.     Icon myicon;
  1428.     myicon.init(10,10,"paint");
  1429.     myicon.show();
  1430.  
  1431.     while(!kbhit()) {
  1432.         if(the_mouse.LBP()) {
  1433.             if(myicon.hit()) {
  1434.                 if(!myicon.ispressed()) {
  1435.                     myicon.choose();
  1436.                     while(the_mouse.LBP());
  1437.                     myicon.show();
  1438.                     }
  1439.                 }
  1440.             }
  1441.         }
  1442.  
  1443.     Usually when an icon has been selected you will want to make 
  1444. sure that the last icon to be selected gets reset to its normal 
  1445. state with a call to "show()." Whatever action needs to be taken 
  1446. as a result of the icon's selection can be done after the call to 
  1447. "choose()." The method "ispressed()" simply returns whether or not 
  1448. the icon is already displayed in its selected state.
  1449.  
  1450.  
  1451.  
  1452.  
  1453. Acticons
  1454.  
  1455.  
  1456.     Acticons are exactly like Icons except that instead of simply 
  1457. reversing their image to mark them as the selected icon, they 
  1458. become animated. Acticons are created using the ICONEDIT program. 
  1459. They are created in the same manner as an Icon, but instead of just 
  1460. a single frame graphic, they contain several (up to 32) frames.
  1461.  
  1462.  
  1463.  
  1464.     Like Icons, they are initialized with a call to "init()" with 
  1465. parameters for the upper left x and y coordinates, and the file 
  1466. name containing the graphic images. When you call "show()", however, 
  1467. you must supply an integer parameter specifying which frame to 
  1468. display. Usually you will want to make this frame 0 because if 
  1469. you call "choose()" the negative image of frame 0 will be displayed 
  1470. by default.
  1471.  
  1472.     For example:
  1473.     
  1474.     Acticon myicon;
  1475.     myicon.init(10,10,"paint");
  1476.     myicon.show(0);
  1477.  
  1478.     Just like an Icon except for the parameter in the call to 
  1479. "show()."       If you want to use choose to show the reverse image of the 
  1480. Acticon it is done the same as it is for class Icon. If however you want 
  1481. to animate the Acticon you must call "animate()" or "backforth()." 
  1482. Both of these methods will put the Acticon in motion. "Animate()" 
  1483. will display the frames in ascending order and then restart at 
  1484. frame 0. "Backforth()" will display the frames in ascending order, 
  1485. but when it reaches the last frame it will then display the frames 
  1486. in reverse order back to frame 0. Both of these methods take a 
  1487. single parameter which specifies the delay between displaying each 
  1488. frame. This delay is expressed in eighteenths of a second. The 
  1489. lower the value, the faster the animation. You do not need to 
  1490. specify the number of frames in the Acticon as this information is 
  1491. contained in the graphic file created by ICONEDIT. Let's take a look:
  1492.  
  1493.     Acticon myicon;
  1494.     myicon.init(10,10,"paint");
  1495.     myicon.show(0);
  1496.  
  1497.     while(!kbhit()) {
  1498.         if(the_mouse.LBP()) {
  1499.             if(myicon.hit()) {
  1500.                 while(the_mouse.LBP()) 
  1501.                     myicon.animate(3);
  1502.                 }
  1503.             }
  1504.         }
  1505.  
  1506.     In this code fragment, if the left mouse key is pressed while the 
  1507. cursor is on the Acticon, then the Acticon will animate for as long 
  1508. as the left mouse key is pressed. Note that "animate()" and 
  1509. "backforth()" will only change the animation by one frame, so for 
  1510. continuous motion you must include calls to these methods within 
  1511. some sort of loop.
  1512.     
  1513.  
  1514.  
  1515.  
  1516. Bitmaps
  1517.  
  1518.  
  1519.  
  1520.     The Bitmap object is used to display and capture graphic images. 
  1521. There are two editors included in this package to create bitmap images. 
  1522. The files are in the Borland getimage() format, which is certainly not 
  1523. the most compressed format for image storage. Future versions of this 
  1524. library are sure to include Bitmap objects with various graphic file 
  1525. formats. The bitmap editors are 16IMAGE.EXE and 256IMAGE.EXE for 
  1526. creating 16 and 256 color bitmaps respectively.
  1527.  
  1528. Bitmap::Bitmap()
  1529.     The default constructor.
  1530.  
  1531.  
  1532. Bitmap::~Bitmap()
  1533.     The default destructor.
  1534.  
  1535.  
  1536. void Bitmap::init(int x,int y)
  1537.     Initializes a bitmap object. The x and y parameter represent the 
  1538.     x,y coordinates for displaying the bitmap. If this coordinate pair 
  1539.     is not known when you initialize the bitmap instance, simply 
  1540.     initialize it to 0,0.   
  1541.  
  1542. void Bitmap::changexy(int x,int y)
  1543.     Changes the x,y coordinates at which to display the bitmap.
  1544.  
  1545.  
  1546.  
  1547. void Bitmap::load(char* name)
  1548.     Loads the bitmap image specified in the name parameter from disk. 
  1549.     This file must have been created by one of the bitmap editors 
  1550.     included with the ObjectEase library, or by a previous call to 
  1551.     Bitmap::save(char*).
  1552.  
  1553.  
  1554. void Bitmap::save(char* name)
  1555.     Saves a bitmap image to disk. Under most circumstances, this will 
  1556.     be an image that has been captured using the 
  1557.     Bitmap::capture(int,int,int,int) member function.
  1558.  
  1559.  
  1560. void Bitmap::capture(int x,int y,int x1,int y1)
  1561.     Captures the area bounded by the rectangle x,y,x1,y1 to a Bitmap 
  1562.     object. This area MUST NOT exceed 64K as this is the maximum size 
  1563.     for a Borland getimage() buffer.
  1564.  
  1565.  
  1566. void Bitmap::moveto(int x,int y)
  1567.     Hides a displyed Bitmap object and re-displays it at the new x,y 
  1568.     coordinates.
  1569.  
  1570.  
  1571. void Bitmap::hide()
  1572.     Removes a displayed Bitmap object from the screen.
  1573.  
  1574.  
  1575. void Bitmap::show_COPY()
  1576.     Displays a Bitmap image using the COPY_PUT mode.
  1577.  
  1578.  
  1579. void Bitmap::show_XOR()
  1580.     Displays a Bitmap object using the XOR_PUT mode.
  1581.  
  1582.  
  1583. void Bitmap::show_OR()
  1584.     Displays a Bitmap object using the OR_PUT mode.
  1585.  
  1586.  
  1587. void Bitmap::show_NOT()
  1588.     Displays a Bitmap using the NOT_PUT mode.
  1589.  
  1590.  
  1591. void Bitmap::show_AND()
  1592.     Displays a Bitmap object using the AND_PUT mode.
  1593.  
  1594.  
  1595. int Bitmap::isshown()
  1596.     Returns 1 if the Bitmap object is displayed on the screen, 0 
  1597.     otherwise.
  1598.  
  1599.  
  1600. int Bitmap::hit()
  1601.     Returns 1 if the mouse cursor is on the Bitmap object, 0 
  1602.     otherwise.
  1603.  
  1604.  
  1605. int Bitmap::xsize()
  1606.     Returns an integer representing the horizontal size of the Bitmap.
  1607.  
  1608.  
  1609. int Bitmap::ysize()
  1610.     Returns an integer representing the vertical size of the Bitmap.
  1611.  
  1612.  
  1613. int Bitmap::bitmapx()
  1614.     Returns the upper left x coordinate of the Bitmap.
  1615.  
  1616.  
  1617. int Bitmap::bitmapy()
  1618.     Returns the upper left y coordinate of the Bitmap.
  1619.  
  1620.  
  1621. int Bitmap::LBSCLK()
  1622.     Returns 1 if the left mouse button has been pressed while the 
  1623.     mouse cursor was on the Bitmap object, 0 otherwise
  1624.  
  1625.  
  1626. int Bitmap::LBDCLK()
  1627.     Returns 1 if the left mouse button was pressed twice while the 
  1628.     mouse cursor was on the Bitmap object. The button must have been 
  1629.     pressed two time with 1/2 of a second or else the timer resets.
  1630.     
  1631.     
  1632. Gstrings
  1633.  
  1634.     No, it's not something a stripper wears, the G in Gstring simply 
  1635. stands for graphic. These object are used for getting text input 
  1636. while in graphics mode. They display their own input fields and can 
  1637. handle all of the text editing keys like arrows, backspace, delete, 
  1638. etc...
  1639.  
  1640.     Once again a call to "init()" is necessary to begin. The necessary 
  1641. parameters are the x and y coordinates of the upper left corner of 
  1642. the input field, the length of the field, and an integer flag to 
  1643. indicate whether of not to force the input into all capital letters. 
  1644. Any nonzero value will force all caps. 
  1645.  
  1646.     Two methods that are part of Tstring that you might find useful 
  1647. are "preset()" and "reset()." Call "preset()" with a string parameter 
  1648. that you wish to have displayed in the input field by default, and 
  1649. "reset()" with no parameters to clear the input field. For example, 
  1650. if you wanted the input field to be displayed with the preset value 
  1651. of "Married" you would use code similar to the following:
  1652.  
  1653.     Gstring mystring;
  1654.     mystring.init(100,10,10,0);
  1655.     mystring.preset("Married");
  1656.     mystring.show();
  1657.  
  1658.     If you don't use the "preset()" method the input field will just 
  1659. be blank, probably what you want in most cases anyway. To allow 
  1660. user input just add the statement:
  1661.     
  1662.     mystring.get_input();
  1663.  
  1664.     This will allow text input until the user presses either <ESCAPE> 
  1665. or <ENTER>. You can test for the <ESCAPE> key with the Tstring 
  1666. method "escapehit()." Let's put it all together...
  1667.  
  1668.     Gstring mystring;
  1669.     char *the_string;
  1670.  
  1671.     mystring.init(100,10,10,0);
  1672.     mystring.get_input();
  1673.     if(mystring.escapehit())
  1674.         exit(0);
  1675.     else
  1676.     strcpy(the_string,mystring.getstring());
  1677.  
  1678.     The Tstring method "getstring()" returns a char * to the actual 
  1679.     text string that was entered by the user.
  1680.  
  1681.  
  1682.  
  1683.  
  1684. Gmenubutton & Gmenu
  1685.  
  1686.     The classes Gmenubutton and Gmenu provide the capabilities for you 
  1687. to include pulldown menus in you graphics applications. The 
  1688. Gmenubutton is simply the text that will appear in the menu bar 
  1689. whereas the Gmenu is the moving bar menu that will pop up when a 
  1690. Gmenubutton is selected. Since these two objects are so closely 
  1691. related I will discuss them together. 
  1692.  
  1693.     The data element gitemarray is a predefined two dimensional 
  1694. array containing the strings that will appear in the Gmenu. 
  1695. The maximum number of items in a Gmenu is 10, and the width of 
  1696. the pop-up menu is fixed at 100 pixels. When initializing the 
  1697. strings in the gitemarray always start at index 1 rather than 
  1698. index 0. Like this:
  1699.  
  1700.     gitemarray menu1array;
  1701.     strcpy(menu1array[1],"ITEM 1");
  1702.     strcpy(menu1array[2],"ITEM 2");
  1703.     etc...
  1704.  
  1705.     A Gmenubutton is initialized with parameters for x and y screen 
  1706. locations, normal state fgd and bgd colors, selected state fgd 
  1707. and bgd colors, and the text to be displayed.
  1708.  
  1709.     A Gmenu is initialized with parameters for the x and y screen 
  1710. locations, the number of entries to be in the menu, and the 
  1711. gitemarray containing the item strings. The Gmenu is popped-up 
  1712. with a call to "show()" which returns an integer representing the 
  1713. index of the gitemarray the bar was on when the selection was made. 
  1714. If no selection was made "show()" returns 11.
  1715.  
  1716.     Let's look at an example to hopefully clear this all up.
  1717.  
  1718.     gitemarray itemarray;
  1719.     Gmenu mymenu;
  1720.     Gmenubutton mymenubutton;
  1721.     int menuchoice;
  1722.  
  1723.     strcpy(itemarray[1],"ITEM 1");
  1724.     strcpy(itemarray[2],"ITEM 2");
  1725.     strcpy(itemarray[3],"ITEM 3");
  1726.     strcpy(itemarray[4],"ITEM 4");
  1727.  
  1728.     setfillstyle(SOLID_FILL,15);        MAKE A MENU BAR AT TOP OF   
  1729.                             SCREEN
  1730.     bar(0,0,getmaxx(),10);
  1731.  
  1732.     mymenubutton.init(0,0,0,15,15,0,"MENU 1");
  1733.     mymenubutton.show();
  1734.  
  1735.     mymenu.init(0,11,4,itemarray);
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.     if(the_mouse.LBP()) {
  1742.         if(mymenubutton.hit()) {
  1743.             mymenubutton.press();
  1744.             choice=mymenu.show();
  1745.             mymenu.hide();
  1746.             mymenubutton.show();
  1747.             }
  1748.         }
  1749.  
  1750.  
  1751.     In this example the integer variable choice will contain the 
  1752. number of the item that was selected. Execution can then branch 
  1753. to the appropriate functions based on this value using case 
  1754. statements.                    
  1755.     
  1756.  
  1757. Screen
  1758.  
  1759.     The final graphics class that we will discuss is the Screen 
  1760. object. This object greatly simplifies the process of putting the screen 
  1761. into various modes. You should use this object to manipulate the screen 
  1762. as it initializes variables which are used by other object instances to 
  1763. determine the current screen mode.
  1764.  
  1765.  
  1766. void Screen::Screen()
  1767.     The default constructor.
  1768.  
  1769.  
  1770. void Screen::~Screen()
  1771.     The default destructor.
  1772.  
  1773.  
  1774. void Screen::VGA_480_16()
  1775.     Puts the screen into 640x480 16 color graphics mode.
  1776.  
  1777.     example:        Screen the_screen;
  1778.                 the_screen.VGA_480_16();
  1779.  
  1780.  
  1781. void Screen::VGA_350_16()
  1782.     Puts the screen into 640x350 16 color graphics mode.
  1783.  
  1784.  
  1785. void Screen::VGA_200_16()
  1786.     Puts the screen into 320x200 16 color graphics mode.
  1787.  
  1788.  
  1789. void Screen::VGA_200_256()
  1790.     Puts the screen into 320x200 256 color graphics mode.
  1791.  
  1792.  
  1793. void Screen::fill(int color)
  1794.     Fills the background of the graphics screen (any mode) with the 
  1795.     color specifies in the color parameter.
  1796.  
  1797.     example:        Screen screen;
  1798.                 screen.VGA256();
  1799.                 screen.fill(48);
  1800.  
  1801.  
  1802.  
  1803.  
  1804. Printing Text
  1805.  
  1806.     Although not part of a class library, there is a text output
  1807. function included in the library that you will find most useful. The
  1808. "outtextxy()" function which is part of the Borland library will only
  1809. take a char* as the parameter to write to the screen. You cannot give
  1810. it a variable to format into a string for you. There is a function in 
  1811. the ObjectEase library called gprintxy() that will format variables into
  1812. printable text for you. The definition is:
  1813.  
  1814.     gprintxy(int,int,char *fmt,...)
  1815.  
  1816.     You can use this function just as you would the "printf()" 
  1817. function in text mode. So for example you could write:
  1818.  
  1819.     int age=27;
  1820.     gprintxy(100,100,"%d",age);
  1821.  
  1822.     "gprintxy()" will format the variable and print it to the screen
  1823. correctly. The two integer parameters represent the x and y position to
  1824. print the string. Remember that this function is dependent on the 
  1825. current text justification settings. Use the Borland library function 
  1826. "settextjustify()" to alter these settings.
  1827.  
  1828.  
  1829.     Next we'll explore the bi-modal objects of the ObjectEase library. 
  1830. That is, objects that can be used in both the text mode and the graphics 
  1831. mode.
  1832.  
  1833.  
  1834.  
  1835.                  Bi-Modal Objects
  1836.  
  1837.     The final discussion of objects in the ObjectEase library will be 
  1838. about the bi-modal objects...objects that can be used in both the text 
  1839. mode as well as the graphics mode. These are the objects SoundQ,and Mcursor.
  1840.  
  1841.     The code for these objects is included in both the TUI libraries
  1842. and the GUI library.
  1843.  
  1844. SoundQ
  1845.  
  1846.     The SoundQ class is used for playing music and sounds in the 
  1847. background while foreground processes continue to execute. This is a 
  1848. feature that you will commonly find in use in game programs, but can be 
  1849. useful in any application. If you're like me, you have probably tried to 
  1850. find some way to do this before, but the necessary functions are simply 
  1851. not available as part of the standard C or C++ libraries. Now you have 
  1852. the tools... you have the POWER...the power of the OBJECT!
  1853.  
  1854.     NOTE: When you include an instance of the SoundQ class in your 
  1855. program the timer chip will be reset to tick 500 times per second. The 
  1856. normal rate for this chip is 18.2 times per second. Clock functions will 
  1857. continue to operate normally as the SoundQ object issues a clock tick at 
  1858. the normal rate of 18.2 times per second, however, you may find that you 
  1859. need to make adjustments in any delays issued by the "void delay(long)" 
  1860. function that comes with the standard library.
  1861.  
  1862.     Let's take a look at the details of the SoundQ class...
  1863.  
  1864. SoundQ::SoundQ
  1865.     The default constructor.
  1866.  
  1867.  
  1868. SoundQ::~SoundQ
  1869.     The default destructor.
  1870.  
  1871.  
  1872. void SoundQ::adjust_speed(float)
  1873.     Adjusts the speed of the sounds being played in the background. 
  1874.     The default value is 1.0. Increasing this value will slow down the 
  1875.     playback, decreasing it will of course speed up the playback. 
  1876.     Changing this value to 2.0 will effectively play back the sounds 
  1877.     at half speed.
  1878.  
  1879.     example:        SoundQ sq;
  1880.                 sq.adjust_speed(2.0);
  1881.  
  1882.  
  1883. void SoundQ::play(int freq,int duration)
  1884.     Places notes in the queue to be played by the SoundQ object. The 
  1885.     notes placed in the queue will begin to play immediately. Remember 
  1886.     that the timer tick has been reset to tick 500 times per second by 
  1887.     the SoundQ object, therefore, to make a note sound for 1 second 
  1888.     the duration parameter must be 500.
  1889.  
  1890.  
  1891.  
  1892.  
  1893.     example:        SoundQ sq;
  1894.                 sq.play(440,100);
  1895.  
  1896.     Note: The following have been defined in the header file, and make  
  1897. the programming of music much simpler:
  1898.  
  1899.     #define C 523   Frequency of Middle C
  1900.     #define CS 554  C Sharp
  1901.     #define D 587   D
  1902.     #define DS 622  D Sharp
  1903.     #define E 659   E
  1904.     #define F 698   F
  1905.     #define FS 740  F Sharp
  1906.     #define G 784   G
  1907.     #define GS 831  G Sharp
  1908.     #define A 880   A
  1909.     #define AS 932  A Sharp (or B Flat)
  1910.     #define B 988   B
  1911.     #define C1 1046 C one octave above middle C
  1912.  
  1913.     #define SN 32   Duration of sixteenth note
  1914.     #define EN 63   Eighth note
  1915.     #define QN 125  Quarter note
  1916.     #define HN 250  Half note
  1917.     #define WN 500  Whole note
  1918.     
  1919.     #define ENT 20  Duration of eighth note triplet
  1920.     #define QNT 41  Duration of Quarter note triplet
  1921.     #define HNT 83  Duration of Half note triplet
  1922.  
  1923.     #define BN 30000,5      Place between two notes of the same     
  1924.                     frequency to clearly define the sounding        
  1925.                     of two notes.
  1926.     #define SR 30000,32     Plays a sixteenth note rest
  1927.     #define ER 30000,63     Plays an eighth note rest
  1928.     #define QR 30000,125    Plays a quarter note rest
  1929.     #define HR 30000,250    Plays a half note rest
  1930.     #define WR 30000,500    Plays a whole note rest
  1931.     #define NM 30000,1      Stops the sounding of a tone. Use at the        
  1932.                     end of a song.
  1933.  
  1934.     Let's use these defines to play the C Major Scale with quarter  
  1935.     notes...
  1936.  
  1937.         SoundQ sq;
  1938.             sq.play(C,QN);
  1939.             sq.play(D,QN);
  1940.             sq.play(E,QN);
  1941.             sq.play(F,QN);
  1942.             sq.play(G,QN);
  1943.             sq.play(A,QN);
  1944.             sq.play(B,QN);
  1945.             sq.play(C1,QN);
  1946.             sq.play(NM);    //used to stop the sound
  1947.  
  1948.  
  1949.     These defined values can be multiplied or divided to play sounds 
  1950. from different octaves. Remember that once you have created a song you 
  1951. only need to use SoundQ::adjust_speed to vary the playback speed of the 
  1952. song.
  1953.  
  1954.  
  1955. Mcursor
  1956.  
  1957.  
  1958.     The Mcursor object controls and gets information about the mouse 
  1959. cursor. Again, this class is available in both text and graphics modes. 
  1960. Several predefined shapes for the graphics mouse cursor have been 
  1961. included in the ObjectEase library, however, at this time there is no 
  1962. provision for including your own designs with the Mcursor class.
  1963.  
  1964.     Note: The instance "Mcursor the_mouse;" has been pre-defined in 
  1965. the header file. This is because many of the objects in this library 
  1966. make use of the Mcursor object on their own. You need to declare this 
  1967. same instance of the Mcursor class within your code or the mouse will 
  1968. not function as you expect. When you declare an Mcursor instance in your 
  1969. code simply declare it as external like this:
  1970.  
  1971.     extern Mcursor the_mouse;       //you MUST name your instance   
  1972.                     //the_mouse
  1973.  
  1974.  
  1975. int Mcursor::init()
  1976.     Initializes the mouse. This function must be called before trying 
  1977.     to use any of the other mouse functions. If a mouse driver is 
  1978.     detected the function will return 1, if no mouse driver is present 
  1979.     it will return 0.
  1980.  
  1981.     example:        extern Mcursor the_mouse;
  1982.                 if(!the_mouse.init()) {
  1983.                     puts("No mouse driver detected");
  1984.                     exit(0);
  1985.                     }
  1986.     The Mcursor instance is immediately put into a state of "unarmed."
  1987.     You must "arm" the instance before it can be displayed.
  1988.  
  1989.  
  1990. void Mcursor::show()
  1991.     Makes the mouse cursor visible on the screen.
  1992.  
  1993.     example:        extern Mcursor the_mouse;
  1994.                 the_mouse.init();
  1995.                 the_mouse.show();
  1996.  
  1997.     Note: upon initialization the state of the mouse cursor will be 
  1998.     visible.
  1999.  
  2000.  
  2001. void Mcursor::hide()
  2002.     Makes the mouse cursor invisible.
  2003.     
  2004.     example:        extern Mcursor the_mouse;
  2005.                 the_mouse.init();
  2006.                 getch();
  2007.                 the_mouse.hide();
  2008.  
  2009.  
  2010. void Mcursor::unarm()
  2011.     Makes the mouse cursor invisible, and keeps other object instances 
  2012. from turning it back on. Any object that needs to draw itself on the 
  2013. screen will turn off the mouse cursor while it is manipulating the 
  2014. screen and then turns it back on when it is finished. If you don't want 
  2015. an object to have the capability of restoring the mouse cursor to the 
  2016. screen you must call Mcursor::unarm().
  2017.  
  2018.     example:        extern Mcursor the_mouse;
  2019.                 the_mouse.init();
  2020.                 the_mouse.unarm();      //hides the mouse cursor 
  2021.                                 //and keeps it from     
  2022.                                 //being restored by     
  2023.                                 //other objects                 
  2024.                                 //instances.
  2025.  
  2026.  
  2027. void Mcursor::arm()
  2028.     Restores the mouse cursor to the screen and allows other object 
  2029. instances to restore it to the screen when they have finished updating 
  2030. the screen. YOU MUST CALL THIS MEMBER FUNCTION AFTER INITIALIZING THE
  2031. MOUSE BECAUSE IT IS UNARMED UPON INITIALIZATION!
  2032.  
  2033.     example:        extern Mcursor the_mouse;
  2034.                 the_mouse.init();
  2035.                 the_mouse.unarm();
  2036.  
  2037.                 ...do some screen manipulation
  2038.  
  2039.                 the_mouse.arm();
  2040.  
  2041.  
  2042. void Mcursor::set_hor_bounds(int left,int right)
  2043.     Sets the horizontal bounds of the mouse cursor movement.
  2044.  
  2045.     example:        extern Mcursor the_mouse;
  2046.                 the_mouse.init();
  2047.                 the_mouse.set_hor_bounds(100,getmaxx()-100);
  2048.                 // the mouse cursor now cannot move closer than 
  2049.                 //100 pixels to the sides of the screen.
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058. void Mcursor::set_ver_bounds(int top,int bottom)
  2059.     Sets the vertical bounds of the mouse cursor movement.
  2060.  
  2061.     example:        extern Mcursor the_mouse;
  2062.                 the_mouse.init();
  2063.                 the_mouse.set_ver_bounds(100,getmaxy()-100);
  2064.                 //the mouse cursor now cannot move closer than  
  2065.                 //100 pixels to the top or bottom of the screen.
  2066.  
  2067.  
  2068. void Mcursor::position(int x,int y)
  2069.     Moves the mouse to the specified coordinates on the screen.
  2070.  
  2071.     example:        extern Mcursor the_mouse;
  2072.                 the_mouse.init();
  2073.                 the_mouse.position(0,0);
  2074.                 //the mouse cursor is now in the upper left     
  2075.                 //corner of the screen. 
  2076.  
  2077.  
  2078. void Mcursor::conditional_off(int x,int y,int x1,int y1)
  2079.     Declares a portion of the screen where the mouse cursor will not 
  2080.     be visible.
  2081.  
  2082.     example:        extern Mcursor the_mouse;
  2083.                 the_mouse.init();
  2084.                 the_mouse.conditional_off(0,0,100,100);
  2085.                 //the mouse cursor will not be visible in the   
  2086.                 //upper left corner of the screen.
  2087.  
  2088.  
  2089. int Mcursor::LBP()
  2090.     Returns 1 if the left mouse button is pressed, 0 otherwise.
  2091.  
  2092.     example:        extern Mcursor the_mouse;
  2093.             int done=0;
  2094.                 the_mouse.init();
  2095.                 while(!done) {
  2096.                     if(the_mouse.LBP()) 
  2097.                         done=1;
  2098.                     }
  2099.                 printf("\a");
  2100.  
  2101. int Mcursor::RBP()
  2102.     Returns 1 if the right mouse button is pressed, 0 otherwise.
  2103.  
  2104.     example:        extern Mcursor the_mouse;
  2105.             int done=0;
  2106.                 the_mouse.init();
  2107.                 while(!done) {
  2108.                     if(the_mouse.RBP()) 
  2109.                         done=1;
  2110.                     }
  2111.                 printf("\a");
  2112.  
  2113. int Mcursor::mx()
  2114.     Returns an integer representing the x coordinate of the mouse 
  2115.     cursor.         
  2116.  
  2117.     example:        extern Mcursor the_mouse;
  2118.             int x;
  2119.                 the_mouse.init();                       
  2120.                 x=the_mouse.mx();
  2121.  
  2122.  
  2123. int Mcursor::my()
  2124.     Returns an integer representing the y coordinate of the mouse 
  2125.     cursor.
  2126.  
  2127.     example:        extern Mcursor the_mouse;
  2128.             int y;
  2129.                 the_mouse.init();
  2130.                 y=the_mouse.my();
  2131.  
  2132.  
  2133. void Mcursor::changeto(int)
  2134.     Changes the shape of the graphics mouse cursor. Has no effect on 
  2135.     the text mode mouse cursor. This function first determines the 
  2136.     current shape of the mouse cursor. If the current shape is the 
  2137.     same as the one you are requesting it to change to the function 
  2138.     will exit with no action taken.
  2139.  
  2140.     example:        extern Mcursor the_mouse;
  2141.                 the_mouse.init();
  2142.                 the_mouse.changeto(CROSSHAIR);
  2143.  
  2144.     Note:   The following cursor shapes are predefined and may be used 
  2145. as the parameter to the Mcursor::changeto(int) function:
  2146.  
  2147.     #define UPARROW 1
  2148.     #define DOT 2
  2149.     #define PENCIL 3
  2150.     #define CROSSHAIR 4
  2151.     #define ARROW 5
  2152.     #define FINGER 6
  2153.     #define POINT 7
  2154.     #define CLOCK 8
  2155.     #define DISK 9
  2156.     #define IBAR 10
  2157.     #define PAINTCAN 11
  2158.     #define HAND 12
  2159.     #define ERASOR 13
  2160.     #define GUNSIGHT 14
  2161.     #define SCISSORS 15
  2162.     #define JAWS 16
  2163.  
  2164.  
  2165.  
  2166.     These are the member functions of the Mcursor class. I'm sure 
  2167. you'll find them as easy to implement as they are powerful to use. In 
  2168. these days of the Graphical User Interface, mouse routines are becoming 
  2169. a standard even in text based applications. These tools out the power of 
  2170. the mouse in your hands.
  2171.  
  2172.  
  2173.  
  2174.     Next I will briefly discuss the many functions that are included 
  2175. in this library that are not necessarily member functions of a 
  2176. particular object.
  2177.  
  2178.  
  2179.  
  2180.  
  2181.         Miscellaneous Functions of the ObjectEase Library
  2182.  
  2183. Note: The designations TUI and GUI included with the following function
  2184. descriptions designate which library the function can be found in.
  2185.  
  2186. TUI
  2187. void vprintat(int cols,int rows,int fore,int back,char *,...);
  2188.     Writes directly to video memory in the specified fgd & bgd colors 
  2189.     at the specified location. Accepts variables in the same way as 
  2190.     the printf() function.
  2191.  
  2192. TUI
  2193. void vprintc(int row,int fore,int back,char *,...);
  2194.     Centers texts directly in video memory at the specified row in the 
  2195.     specified fgd & bgd colors. Accepts variables in the same way as 
  2196.     the printf() function.
  2197.  
  2198. TUI
  2199. void printat(int,int,int,int,char *);
  2200.     Same as vprintat, however, only literal text is accepted, not 
  2201.     variables.
  2202.  
  2203. TUI
  2204. void printc(int,int,int,char *);
  2205.     Same as vprintc, however, only literal text is accepted, not 
  2206.     variables.
  2207.  
  2208. TUI
  2209. void cprintat(int,int,int,int,char *,...);
  2210.     Same as vprintat, however, the cursor is moved to the end of the 
  2211.     string after the write.
  2212.  
  2213. TUI
  2214. void cprintc(int,int,int,char *,...);
  2215.     Same as vprintc, however, the cursor is moved to the end of the 
  2216.     string after the write.
  2217.  
  2218. TUI
  2219. void clear(char ch,int fore,int back);
  2220.     Fills video memory with the specified character in the specified 
  2221.     fgd & bgd colors.
  2222.  
  2223. TUI
  2224. void cursoroff();
  2225.     Turns off the text cursor.
  2226.  
  2227. TUI
  2228. void cursoron();
  2229.     Turns on the text cursor.
  2230.  
  2231. TUI
  2232. void settext(int fgd,int bgd);
  2233.     Sets the current text attributes to the specified fgd & bgd 
  2234.     colors.
  2235.  
  2236. TUI
  2237. void chsattr(int fgd,int bgd);
  2238.     Changes the attributes of the entire screen to the specified fgd & 
  2239.     bgd colors, leaving all character info on the screen intact.
  2240.  
  2241. TUI
  2242. void chcattr(int xpos,int ypos,int length,int fgd,int bgd);
  2243.     Changes the screen attributes to the specified fgd & bgd colors 
  2244.     starting at xpos,ypos and continuing for length characters.
  2245.  
  2246. TUI/GUI
  2247. void dlay(int ticks);
  2248.     Causes a delay of the specified number of clock ticks. Clock ticks 
  2249.     occur 18.2 times per second.
  2250.  
  2251. TUI/GUI
  2252. long getticks();
  2253.     Returns the time as a long number representing the number of clock 
  2254.     ticks since the preceding midnight.
  2255.  
  2256. TUI/GUI
  2257. int altkey();
  2258.     Returns 1 if an ALT key is pressed, 0 otherwise.
  2259.  
  2260. TUI/GUI
  2261. int ctrlkey();
  2262.     Returns 1 if a CTRL key is pressed, 0 otherwise.
  2263.  
  2264. TUI/GUI
  2265. int lshiftkey();
  2266.     Returns 1 if the LEFT SHIFT key is pressed, 0 otherwise.
  2267.  
  2268. TUI/GUI
  2269. int rshiftkey();
  2270.     Returns 1 if the RIGHT SHIFT key is pressed, 0 otherwise.
  2271.  
  2272. TUI/GUI
  2273. void flushkeys();
  2274.     Clears any and all keypresses from the keyboard buffer.
  2275.  
  2276. TUI/GUI
  2277. unsigned char getvidmode();
  2278.     Returns an unsigned char value representing the current video 
  2279.     mode.
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.     The remaining functions are all part of the VIDBIOSS & VIDBIOSL
  2286. libraries.
  2287.  
  2288. void set_default_palette();
  2289.     Sets all palette values to their initial values.
  2290.  
  2291. void blankcolor(int);
  2292.     Sets the palette values of the color specified to 0,0,0. In other 
  2293.     words to BLACK.
  2294.  
  2295. void fade1_3();
  2296.     Fades any object or text displayed from color 1, BLUE, to color 3, 
  2297.     CYAN.
  2298.  
  2299. void fade3_1();
  2300.     Fades any object or text displayed from color 3, CYAN, to color 1, 
  2301.     BLUE.
  2302.  
  2303. void fade1_4();
  2304.     Fades any object or text displayed from color 1, BLUE, to color 4, 
  2305.     RED.
  2306.  
  2307. void fade4_1();
  2308.     Fades any object or text displayed from color 4, RED, to color 1, 
  2309.     BLUE.
  2310.  
  2311. void fade1_5();
  2312.     Fades any object or text displayed from color 1, BLUE, to color 5, 
  2313.     MAGENTA.
  2314.  
  2315.  
  2316.  
  2317. void fade5_1();
  2318.     Fades any object or text displayed from color , MAGENTA, to color 
  2319.     1, BLUE.
  2320.  
  2321. void fadein(int color);
  2322.     Fades the specified color from 0,0,0, (BLACK) to its normal 
  2323.     palette value.
  2324.  
  2325. void fadeout(int color);
  2326.     Fades the specified color from its normal palette value to 0,0,0 
  2327.     (BLACK).
  2328.  
  2329. void rgb(int color,int R,int G,int B);
  2330.     Sets the specified color to the specified values of Red, Green, 
  2331.     and Blue. Valid RGB values are from 0 to 63.
  2332.  
  2333. void make_grayscale();
  2334.     Resets the normal palette to its grayscale equivalents.
  2335.  
  2336. void screenbord(int);
  2337.     Makes the screen border the color specified.
  2338.  
  2339. void disable_blink();
  2340.     Disables the ability to make characters blink, however, this 
  2341.     allows you to use colors 8 through 15 as background colors in text 
  2342.     mode.
  2343.  
  2344. void enable_blink();
  2345.     Restores the ability to make characters blink, however, colors 8 
  2346.     through 15 will not be available for use as background colors in 
  2347.     the text mode.
  2348.  
  2349. void disable_refresh();
  2350.     Disables the video refresh, effectively blanking the screen.
  2351.  
  2352. void enable_refresh();
  2353.     Enables the video refresh, restoring a screen blanked by a call to 
  2354.     disable_refresh().
  2355.  
  2356.  
  2357.